<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<head>
    <meta charset="utf-8">
    <title>飞行试验奖惩项目管理信息列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
    <table id="wFlightRewardsProjectTable" lay-filter="wFlightRewardsProjectTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="wFlightRewardsProjectHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <@f.a alias="fxsyjcxm_xzan2" event="add" css="layui-btn layui-btn-sm fillBtn" >
                <span>新增</span>
            </@f.a>

            <@f.a alias="fxsyjcxm_scan2" event="delete" css="layui-btn layui-btn-sm" >
                <span>删除</span>
            </@f.a>

            <@f.a alias="fxsyjcxmgl_dcan1,fxsyjcxmgl_dcan2" event="export" css="layui-btn layui-btn-sm" >
                <span>导出</span>
            </@f.a>

            <@f.a alias="fxsyjcxm_dran2" event="import" css="layui-btn layui-btn-sm" >
                <span>导入</span>
            </@f.a>
            <@f.a alias="fxsyjcxmgl_sban2" event="report" css="layui-btn layui-btn-sm" >
                <span>上报</span>
            </@f.a>
        </div>
        <form class="layui-form" action="" lay-filter="wFlightRewardsProjectQueryForm" >
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <@SourceDept.dept css="layui-input filter-value" showIn="0"/>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">型号名称</label>
                        <div class="layui-input-block">
                            <select name="Q_modelname_S" class="layui-input filter-value" lay-search="">
                                <option value=""></option>
                            </select>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目类型</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_projecttype_SL" css="layui-input filter-value" search=true nodeKey="xmlx" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目类别</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_projectcategory_SL" css="layui-input filter-value" search=true nodeKey="xmlb" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目阶段</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_projectstage_SL" css="layui-input filter-value" search=true nodeKey="xmjd" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">项目主管部门</label>
                        <div class="layui-input-block">
                            <@dicSelect.dic name="Q_projectdepartment_SL" css="layui-input filter-value" search=true nodeKey="zgbm" />
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                            <label class="layui-form-label">飞行试验名称</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_flighttestname_SL" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">年度</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value dateTimeFiled time-init year" name="Q_beginYear_S" placeholder="请输入"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">是否临时</label>
                        <div class="layui-input-block">
                            <select name="Q_istemp_S" class="layui-input filter-value" lay-search="">
                                <option value=""></option>
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>
                    <!--项目临时计划是个啥 梅晓冬没回复，没有写-->
                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen" style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="wFlightRewardsProjectRightToolsBar">
    {{# if('${currentUserId}'==d.createBy &&  d.allowEdit ){}}
    <@f.a alias="fxsyjcxm_bjan2" event="edit" css="RightBtn">编辑</@f.a>
    {{#  } }}

    <@f.a alias="fxsyjcxmgl_mxan1,fxsyjcxmgl_mxan2" event="particulars" css="RightBtn">详情</@f.a>

    {{# if('${currentUserId}'==d.createBy && d.allowDel ){}}
    <@f.a alias="fxsyjcxm_scan2" event="del" css="RightBtn">删除</@f.a>
    {{#  } }}

</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','table', 'form', 'common','publicMethods','jquery','layer','laydate','propsHandle'], function () {
        var table = layui.table;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        var laydate = layui.laydate;
        var propsHandle = layui.propsHandle;
        var defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                selectorBtn: '.selectorBtn'
            },
            temQuery = new propsHandle();  // 实例化模板功能部分
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });

        var tableH=publicMethods.tabHeight();

        var currentSystemLevel = "${currentSystemLevel}";

        var diyCols = [];
        // if ("GROUPLEVEL" !== currentSystemLevel) {
        //     diyCols = [{field: 'fReportStatus', title: '上报状态',sort:false, sortname: 'f_report_status'}];
        // }
        if ("GROUPLEVEL" !== currentSystemLevel) {
            diyCols = [{field: 'reportStatusStr', minWidth: '140',title: '状态',sort:false, sortname: 'REPORT_STATUS',templet: function(d){
                return common.stateType(d);
            }}];
        }

        var commonCols = [ //表头
            {type: 'checkbox', fixed: 'left'}
            ,{field: 'sn', type: 'numbers', title: '序号', fixed: 'left'}
            // ,{field: 'id', title: '主键id',sort:true, sortname: 'id'}
            //如需转换为:yyyy-MM-dd HH:mm:ss: return publicMethods.timeData(d.year,"1");
            //如需转换为HH:mm:ss: return publicMethods.timeData(d.year,"2");
            // 当前转换后的格式为yyyy-MM-dd: return publicMethods.timeData(d.year);
            ,{field: 'year', title: '年度',minWidth:80,sort:false, sortname: 'year',templet: function (d) {
                return publicMethods.timeData(d.year,"3");
            }}
            ,{field: 'modelname', title: '型号名称',minWidth:110,sort:false, sortname: 'modelname'}
            ,{field: 'totalityunitcode', title: '总体单位名称',minWidth:140,sort:false, sortname: 'totalityunitcode'}
            ,{field: 'secret', title: '密级',minWidth:80,sort:false, sortname: 'secret'}
            ,{field: 'projecttype', title: '项目类型',minWidth:110,sort:false, sortname: 'projecttype'}
            ,{field: 'projectcategory', title: '项目类别',minWidth:110,sort:false, sortname: 'projectcategory'}
            ,{field: 'projectstage', title: '项目阶段',minWidth:110,sort:false, sortname: 'projectstage'}
            ,{field: 'flighttestname', title: '飞行试验名称',minWidth:140,sort:false, sortname: 'flighttestname'}
            ,{field: 'bonusgiven', title: '奖励额度(万元)',minWidth:150,sort:false,align: 'right', sortname: 'bonusgiven',templet: function (d) {
                if (d.bonusgiven != null){
                    return '<span style="color: #F07878">'+d.bonusgiven+'</span>';
                }else {
                    return '<span style="color: #F07878">'+0+'</span>';
                }
            }}
            ,{field: 'penaltyamount', title: '处罚额度(万元)',minWidth:150,sort:false,align: 'right', sortname: 'penaltyamount',templet: function (d) {
                if (d.penaltyamount != null){
                    return '<span style="color: #F07878">'+d.penaltyamount+'</span>';
                }else {
                    return '<span style="color: #F07878">'+0+'</span>';
                }
            }}
            ,{field: 'productprice', title: '产品价格(万元)',minWidth:150,sort:false,align: 'right', sortname: 'productprice',templet: function (d) {
                if (d.productprice != null){
                    return '<span style="color: #F07878">'+d.productprice+'</span>';
                }else {
                    return '<span style="color: #F07878">'+0+'</span>';
                }
            }}
            ,{field: 'projectdepartment', title: '项目主管部门',minWidth:140,sort:false, sortname: 'projectdepartment'}
            ,{field: 'istemp', title: '是否临时',minWidth:110,sort:false, sortname: 'istemp'}
            // ,{field: 'accessory', title: '附件',sort:true, sortname: 'accessory'}
            // ,{field: 'remark', title: '备注',sort:true, sortname: 'remark'}
            // ,{field: 'reportStatusTemp', title: '三级上报状态',sort:true, sortname: 'report_status_temp'}

        ];

        var manageCols = [{
            fixed: 'right',
            title: '管理',
            width: 80,
            toolbar: '#wFlightRewardsProjectRightToolsBar'
        }]

        var totalCols = [];
        totalCols = totalCols.concat(commonCols).concat(diyCols).concat(manageCols);


        //第一个实例
            table.render({
            elem: '#wFlightRewardsProjectTable'
            ,height:tableH
            ,url: '${ctx}/qbdms/wFlightRewardsProject/list'
            ,page: publicMethods.pageFun()
            ,toolbar: '#wFlightRewardsProjectHeaderToolsBar'
            ,method: 'post'
            ,defaultToolbar: ['']
            ,autoSort: false //是否排序
            ,limit:20
            ,cols: [totalCols],done:function () {
                table.resize("wFlightRewardsProjectTable");
                common.tableSelectCon('.ccpui-enterSel .layui-form input','a[lay-event=query]','.ccpui-enterSel');

                //-- 页面初始化状态 开始 ------------------------------------------------------------------
                // $(".layui-icon-up").trigger("click");
                //-- 页面初始化状态 结束 ------------------------------------------------------------------
            }
            ,parseData: function(res){ //res 即为原始返回的数据
                common.parseDataList(res,['istemp']);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });

        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('wFlightRewardsProjectTable',true);

        //-- 初始化 数据字典 开始 --------------------------------------------------------------
        var xhdhList = eval('${xhdhList}'); //型号代号
        var initXHDH = function(optionObj, item){
            optionObj.text = item.fModelname;
            optionObj.value = item.fModelname;
        };
        common.initDicData("Q_modelname_S", xhdhList, "", initXHDH);


        //-- 初始化 数据字典 结束 --------------------------------------------------------------

        function dateReflash() {

            var dateTimeFiledLen = $(".dateTimeFiled");
            var currentDate = new Date();
            var currentYear = currentDate.getFullYear();
            for(var i=0;i<dateTimeFiledLen.length;i++){
                laydate.render({
                    elem: dateTimeFiledLen[i] //指定元素
                    ,type: 'year'
                    ,trigger: 'click'
                });
            }

        }


        function reflashQuery(isClear) {
            common.tableConditionRender("wFlightRewardsProjectTable","wFlightRewardsProjectQueryForm",{where:{}},isClear);
            common.initDicData("Q_modelname_S", xhdhList, "", initXHDH);
        }

        table.on('toolbar(wFlightRewardsProjectTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/wFlightRewardsProject/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    delFun(data,array);
                    break;
                case 'export':
                function open(url , param){
                    var curUrl = url;
                    layer.open({
                        type: 2,
                        area: ['700px', '520px'],
                        title: ['自定义导出', 'font-size:14px;'],
                        content: '${ctx}/qbdms/wFlightRewardsProject/view/export',
                        btnAlign: 'c',
                        skin: 'qbdms-layerFormBtn',
                        btn: ['确定', '取消'],
                        yes: function(index, layero){
                            url = curUrl;
                            var iframeWin = window["layui-layer-iframe" + index];
                            var data = iframeWin.getData();
                            if(data){
                                url = url + "?data=" + JSON.stringify(data) + param;
                                window.location.href = encodeURI(url)
                            }
                        }
                    });
                }
                    if (data.length == 0) {
                        layer.confirm(publicMethods.confirmStyle('还没有选择，是否导出全部？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var url = '${ctx}/qbdms/wFlightRewardsProject/exportData';
                            var param = "";
                            $("form[lay-filter='wFlightRewardsProjectQueryForm']").find(".filter-value").each(function(i,value) {
                                param += "&"+this.name+"="+this.value
                            });
                            open(url , param);
                        });
                    } else {
                        layer.confirm(publicMethods.confirmStyle('确定导出吗？'),{title: false,skin: 'confirm-class'}, function (index) {
                            layer.close(index);
                            var ids = [];
                            for (var i = 0; i < data.length; i++) {
                                ids.push(data[i].id);
                            }
                            var url = '${ctx}/qbdms/wFlightRewardsProject/exportData';
                            open(url , "&id="+ids);
                        });
                    }
                    break;
                case "import":
                    common.importInit('wFlightRewardsProjectTable',"/qbdms/wFlightRewardsProject/importData",true,"/importTemplates/飞行试验奖惩项目管理.xlsx");
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "query":
                    reflashQuery(false);
                    dateReflash();
                    break;
                case "screen":
                    common.initScreenTop('wFlightRewardsProjectTable');
                    dateReflash();
                    form.render();
                    break;
                case "clears":
                    reflashQuery(true);
                    dateReflash();
                    break;
                case "report":
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array+=data[i].id+",";
                    }
                    //业务表名,勾选数据主键,流程key,table标签lay-filter属性值,form标签lay-filter属性值,是否允许重复上报,页面所在包名,流程定义id
                    common.report("w_flight_rewards_project",array,"plantToHospital","wFlightRewardsProjectTable","wFlightRewardsProjectQueryForm",false,"wFlightRewardsProject","plantToHospital:1:72d05d40362249118c5453aa60c6da90");
                    dateReflash();
                    break;

            };
        });

        table.on('tool(wFlightRewardsProjectTable)', function(obj) {
            var data = obj.data, //获得当前行数据
                    layEvent = obj.event; //获得 lay-event 对应的值
            switch(layEvent){
                case "edit":
                    window.location.href = '${ctx}/qbdms/wFlightRewardsProject/view/add?id='+data.id
                    break;
                case "particulars":
                    window.location.href = '${ctx}/qbdms/wFlightRewardsProject/view/particulars?id='+data.id;
                    break;
                case "del":
                    delFun(data,data.id);
                    break;
            }
        });

        function delFun(data,id) {
            if (data.length === 0) {
                layer.alert(publicMethods.confirmStyle('请先选择一行数据!'),{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'),{title: false,skin: 'confirm-class'}, function (index) {
                    layer.close(index);
                    $.ajax({
                        url:"${ctx}/qbdms/wFlightRewardsProject/del",
                        type: "post",
                        data: {id:id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg),{title: false,skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                            dateReflash();
                        }
                    })
                })
            }
        }
        dateReflash();

        window.Initialization = function () {
            dateReflash();
            reflashQuery(true);
        };
        /*刷新时间控件*/
        common.tableSort("wFlightRewardsProjectTable",{show:dateReflash});
    });
</script>
<style>
    dl{
        width: 100%
    }
</style>
</body>
</html>